#include <stdio.h>
#include <stdlib.h>

#define MAXSIZE 10
#define NotFound -1
typedef int ElementType;

typedef int Position;
typedef struct LNode *List;
struct LNode
{
    ElementType Data[MAXSIZE];
    Position Last; /* 保存线性表中最后一个元素的位置 */
};

List ReadInput(); /* 裁判实现，细节不表。元素从下标1开始存储 */
Position BinarySearch(List L, ElementType X);

int main()
{
    List L;
    ElementType X;
    Position P;

    L = ReadInput();
    scanf("%d", &X);
    P = BinarySearch(L, X);
    printf("%d\n", P);

    return 0;
}
List ReadInput()
{
    List L; //初始化顺序表
    L = (List)malloc(sizeof(struct LNode));
    L->Last = -1;

    int n;
    scanf("%d", &n);
    L->Last = n ;
    for (int i = 1; i < (n+1); i++)
    {
        scanf("%d", &L->Data[i]);
    }
    return L;
}
Position BinarySearch( List L, ElementType X )
{
    Position begin = 1;
    Position end = L->Last;
    while(begin <= end) {
        Position mid = (begin + end) /2;
        if(L->Data[mid] > X) 
            end = mid - 1;
        else if(L->Data[mid] < X) 
            begin = mid + 1;
        else return mid;
    }
    return NotFound;
}
// Position BinarySearch(List L, ElementType X)
// {
//     int left = 0, right = L->Last, center;
//     while (left <= right)
//     {
//         center = (right + left) / 2;
//         if (X < L->Data[center])
//         {
//             right = center-1;
//         }
//         else if (X > L->Data[center])
//         {
//             left = center +1;
//         }

//         else
//             return center;
//     }
//     return NotFound;
// }
